package com.hardson.toolkit.listcomparator;

public class DefaultListComparator<T> extends ListComparator<T> {

	public DefaultListComparator() {

	}

	@Deprecated
	public DefaultListComparator(final String colName, final Class<T> clazz, final int order) {
		this.colName = colName;
		this.cl = clazz;
		this.order = order;
	}

	public DefaultListComparator(final String colName, final int order) {
		this.colName = colName;
		this.order = order;
	}

	@SuppressWarnings("unchecked")
	@Override
	public int compare(final T t1, final T t2) {
		T swapObj[] = this.swap(t1, t2);
		Object val0 = this.getValueObj(swapObj[0]);
		Object val1 = this.getValueObj(swapObj[1]);
		Integer result = this.compareNull(val0, val1);
		if (result != null) {
			return result;
		}
		Comparable<Comparable<T>> cmp0 = (Comparable<Comparable<T>>) val0;
		Comparable<T> cmp1 = (Comparable<T>) val1;
		return cmp0.compareTo(cmp1);
	}

}
